package main

import (
	"fmt"
	"math/rand"
	"sort"
)

func Raint(count int) []int {
	var (
		flag, a int = 0, 0
	)
	b := make([]int, 0, count)

	fmt.Println(b, cap(b))
	for i := 0; i < 100; i++ {
		flag = rand.Intn(2)
		if flag == 1 {
			a = rand.Intn(65535) % 100
		} else {
			a = -rand.Intn(65535) % 100
		}
		b = append(b, a)

	}
	return b
}

func countfunc(b []int) {
	c := make(map[int]int, len(b))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	fmt.Println(b)
	for _, v := range b {
		c[v] += 1
	}
	for k, v := range c {
		fmt.Printf("此数字:%d 出现了 %d次\n", k, v)
	}

}

func third_question() {
	b := Raint(100)
	countfunc(b)
}
func second_question() {
	a := make([]int, 0, 10)
	var count int = 0
	b := []int{1, 4, 9, 16, 2, 5, 10, 15}
	for i := 0; i < len(b); i++ {

		if len(b) == i+1 {
			break
		}
		count = b[i] + b[i+1]
		a = append(a, count)
	}
	fmt.Println(a)
}

func main() {
	second_question()
	third_question()

}
